<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2016/10/11
  Time: 15:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="stateStr" value="启用,禁用"/>
<c:set var="delim" value=","/>
<c:set var="stateCoverArr" value="${fn:split(stateStr, delim)}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>消息节点修改页面</title>
    <link href="../../css/msgBox/nodeModify.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../js/jquery/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".customHidden").hide();
            $(".customHidden:first").show();
            $(".customTemplate").click(function () {
                $(".customHidden").hide();
                var activeTab = $(this).find("a").attr("href");
                $(activeTab).fadeIn();
                return false;
            });
        });

        function doSave() {
            $.ajax({
                       cache: true,
                       type: "POST",
                       url: "./doSave",
                       data: $('#msgForm').serialize(),
                       async: false,
                       error: function (request) {
                           alert("Connection error");
                       },
                       success: function (data) {
                           alert(data.msg);
                       }
                   });
        }
    </script>
</head>

<body>
<div class="nodeModify">
    <form action="" id="msgForm" name="msgForm">
        <input name="id" value="${msgBox.id}" type="hidden"/>
        <input name="name" value="${msgBox.name}" type="hidden"/>
        <table class="tableModify" cellspacing="0" cellpadding="0">
            <tr class="customTitle">
                <td class="tdWidth">节点名称</td>
                <td class="tdWidth">电子邮件模版</td>
                <td class="tdWidth">短信模板</td>
                <td class="tdWidth">站内信模版</td>
                <td class="tdWidth">电子邮件状态</td>
                <td class="tdWidth">短信状态</td>
                <td class="tdWidth">站内信状态</td>
                <td class="tdWidth">配置启用状态</td>
                <td class="customWidth">操作</td>
            </tr>
            <tr class="documentsReview">
                <td class="tdWidth customReview">${msgBox.name}</td>
                <td class="tdWidth customTemplate"><a href="#text1">
                    <c:choose>
                        <c:when test="${fn:length(msgBox.mailTemplate) > 5}">
                            <c:out value="${fn:substring(msgBox.mailTemplate, 0, 5)}..."/>
                        </c:when>
                        <c:otherwise>
                            <c:out value="${msgBox.mailTemplate}"/>
                        </c:otherwise>
                    </c:choose>
                </a></td>
                <td class="tdWidth customTemplate"><a href="#text2">
                    <c:choose>
                        <c:when test="${fn:length(msgBox.smsTemplate) > 5}">
                            <c:out value="${fn:substring(msgBox.smsTemplate, 0, 5)}..."/>
                        </c:when>
                        <c:otherwise>
                            <c:out value="${msgBox.smsTemplate}"/>
                        </c:otherwise>
                    </c:choose>
                </a></td>
                <td class="tdWidth customTemplate"><a href="#text3">
                    <c:choose>
                        <c:when test="${fn:length(msgBox.internalMsgTemplate) > 5}">
                            <c:out value="${fn:substring(msgBox.internalMsgTemplate, 0, 5)}..."/>
                        </c:when>
                        <c:otherwise>
                            <c:out value="${msgBox.internalMsgTemplate}"/>
                        </c:otherwise>
                    </c:choose>
                </a></td>
                <td class="tdWidth customState">

                    <select name="mailState">
                        <option value="0" <c:if test="${msgBox.mailState eq '0'}">selected</c:if>>启用
                        </option>
                        <option value="1" <c:if test="${msgBox.mailState eq '1'}">selected</c:if>>禁用
                        </option>
                    </select>
                </td>
                <td class="tdWidth customState">
                    <select name="smsState">
                        <option value="0" <c:if test="${msgBox.smsState eq '0'}">selected</c:if>>启用
                        </option>
                        <option value="1" <c:if test="${msgBox.smsState eq '1'}">selected</c:if>>禁用
                        </option>
                    </select>
                </td>
                <td class="tdWidth customState">
                    <select name="internalMsgState">
                        <option value="0"
                                <c:if test="${msgBox.internalMsgState eq '0'}">selected</c:if>>启用
                        </option>
                        <option value="1"
                                <c:if test="${msgBox.internalMsgState eq '1'}">selected</c:if>>禁用
                        </option>
                    </select>
                </td>
                <td class="tdWidth customState">
                    <select name="settingState">
                        <option value="0"
                                <c:if test="${msgBox.settingState eq '0'}">selected</c:if>>启用
                        </option>
                        <option value="1"
                                <c:if test="${msgBox.settingState eq '1'}">selected</c:if>>禁用
                        </option>
                    </select>
                </td>
                <td class="customWidth">
                    <a class="modification" href="javascript:doSave();">保存</a>
                    <a class="modification" href="javascript:history.back();">返回</a>
                </td>
            </tr>
        </table>
        <div class="customText">
        <textarea rows="20" class="customHidden" id="text1"
                  name="mailTemplate">${msgBox.mailTemplate}</textarea>
        <textarea rows="20" class="customHidden" id="text2"
                  name="smsTemplate">${msgBox.smsTemplate}</textarea>
        <textarea rows="20" class="customHidden" id="text3"
                  name="internalMsgTemplate">${msgBox.internalMsgTemplate}</textarea>
        </div>
    </form>
</div>
</body>
</html>
